Calling the NAG C Library (DLL) from C#The NAG C Library uses the following data types as parameters. These are:
As a first step towards making the C Library functions available to the .NET environment, an assembly of imports is needed. This contains:
The file NagCFunctionsAPI.cs contains signatures of a number of NAG C Library routines and call-back functions. It also contains layouts of some structures used in the library, in particular the NagError structure which is used by almost all the routines in the library. One of the most useful areas of the library is optimisation. We have provided the layout for the Nag_E04_Opt structure along with the signatures for nag_opt_nlp (e04ucc) and the call-backs, NAG_E04UCC_OBJFUN and NAG_E04UCC_CONFUN, which are required by this routine. Some enum types have also been provided. We have also provided basic C# classes for illustrative purposes. These can be found in the files listed below. For example a sample C# class calling e04ucc can be found in e04ucce.cs. Each of the illustrative classes has a Main method exercising the NAG C example as shown in the C Library manual. If there are particular routines whose signatures cannot be determined from the information we have provided please contact us. We will try our best to help.
These examples may be compiled from the command line (e.g. from a Visual Studio Command Prompt) in the following manner: csc /unsafe d01ajce.cs NagCFunctionsAPI.cs Note that because calling NAG C Library functions involves the use of pointers (see above), the "unsafe" compiler option must be specified. The function declarations in NagCFunctionsAPI.cs are based on the stand-alone version of the NAG C Library DLL (CLDLL084Z_nag.dll); to specify the version of the DLL which uses the MKL BLAS/LAPACK instead (CLDLL084Z_mkl.dll), replace CLDLL084Z_nag.dll by CLDLL084Z_mkl.dll in the DllImport attribute. Remember also that to be able to run the program after you have
compiled it, the NAG C Library DLL will need to appear somewhere in
your current path. For example, if the DLLs are in
C:\Program Files\NAG\CL08\cldll084zl\bin;C:\Program Files\NAG\CL08\ cldll084zl\MKL_ia32_8.0\bin;<rest of path> |
© Numerical Algorithms Group
Visit NAG on the web at:
www.nag.co.uk (Europe and ROW)
www.nag.com (North America)
www.nag-j.co.jp (Japan)
http://www.nag.co.uk/numeric/CL/classocinfo/csharp/csharpinfo.asp